﻿namespace ManagerClinic.CanLamSang
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using DevExpress.XtraEditors;
    using ManagerClinic.Core.Common;
    using ManagerClinic.Core.Business;
    using ManagerClinic.Modules;
    using ManagerClinic.Ultilities.Ultility;
    public partial class frmDanhSachPhieuThamDoChucNang : DevExpress.XtraEditors.XtraForm
    {
        PhieuThamDoChucNangBusiness objPhieuThamDoCNbusiness = new PhieuThamDoChucNangBusiness();
        PhieuThamDoChucNangEntity objPhieuThamDoCN = null;
        IList<PhieuThamDoChucNangEntity> lstPhieuThamDoCN = null;
        public frmDanhSachPhieuThamDoChucNang()
        {
            InitializeComponent();
        }

        private void grdDanhSachBenhNhanKhamBenh_DoubleClick(object sender, EventArgs e)
        {
            if (gvDanhSachBenhNhanKhamBenh.RowCount > 0)
            {
                frmPhieuThamDoChucNang frm = new frmPhieuThamDoChucNang((int)ConstantManagerClinic.StateInsertOrUpdate.Update, fcnMaThamDoCN());
                frm.ShowDialog();
            }
        }
        string fcnMaThamDoCN()
        {
            if (gvDanhSachBenhNhanKhamBenh.RowCount > 0)
            {
                objPhieuThamDoCN = (PhieuThamDoChucNangEntity)gvDanhSachBenhNhanKhamBenh.GetFocusedRow();
                return objPhieuThamDoCN.MaThamDoChucNang;
            }
            else
                return null;
        }
        void LoadData(int trangthai)
        {
            lstPhieuThamDoCN = objPhieuThamDoCNbusiness.GetPhieuThamDoChucNangByTrangThai(trangthai);
            if (lstPhieuThamDoCN != null)
                grdDanhSachBenhNhanKhamBenh.DataSource = lstPhieuThamDoCN;
        }

        private void btnDong_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void radTrangThaiKhamBenh_SelectedIndexChanged(object sender, EventArgs e)
        {
            LoadData(radTrangThaiKhamBenh.SelectedIndex);
        }

        private void frmDanhSachPhieuThamDoChucNang_Load(object sender, EventArgs e)
        {
            LoadData(radTrangThaiKhamBenh.SelectedIndex);
        }

    }
}